Skip to content

examples: add pod_node_selector example for V1PodSpec - #2814

Merged
kubernetes-prow[bot] merged 1 commit into
kubernetes-client:masterfrom
anisayakmitra-in:example-pod-node-selector
Nov 28, 2026
Merged

kubernetes-prow[bot] merged 1 commit into
kubernetes-client:masterfrom
anisayakmitra-in:example-pod-node-selector

Conversation

@anisayakmitra-in

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind documentation

What this PR does / why we need it:

Adds an example script examples/pod_node_selector.py demonstrating how to assign a Pod to specific cluster nodes using node_selector in client.V1PodSpec.

The example covers:

  • Discovering cluster nodes and inspecting node labels (v1.list_node()).
  • Configuring client.V1PodSpec with node_selector={"kubernetes.io/os": "linux"} (mapping to spec.nodeSelector).
  • Creating the namespaced Pod via v1.create_namespaced_pod.
  • Waiting for the scheduler to bind the Pod and verifying pod.spec.node_name.
  • Cleaning up the created Pod.
  • Indexing the script in examples/README.md.

Which issue(s) this PR fixes:

Fixes #1934

Special notes for your reviewer:

None

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

None

Signed-off-by: ANISAYAK MITRA <266799942+anisayakmitra-in@users.noreply.github.com>
@kubernetes-prow kubernetes-prow Bot added release-note-none Denotes a PR that doesn't merit a release note. kind/documentation Categorizes issue or PR as related to documentation. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 28, 2026
@kubernetes-prow
kubernetes-prow Bot requested review from roycaihw and yliaog November 28, 2026 04:25
@kubernetes-prow kubernetes-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 28, 2026
@yliaog

yliaog commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 28, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: anisayakmitra-in, yliaog

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 28, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit 6deb352 into kubernetes-client:master Nov 28, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/documentation Categorizes issue or PR as related to documentation. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Please can you provide an example of node_selector in V1PodSpec

2 participants